<?php

class Sessions extends CI_Controller
{
	
    public function __construct()
    {
        parent::__construct();
        $this->load->library('session');
    }

    public function login()
    {
    	$this->load->helper('url');
    	$this->load->helper('form');
        $this->load->view('admin/login');
    }

    public function authenticate()
    {
    	$this->load->helper('url');
    	if($this->input->post('username') == "admin" && $this->input->post('password') == "adm123")
    	{
    		$this->session->set_userdata('loggedin', true);
            redirect('/admin/home');
    	}
    	else
    		redirect('/sessions/login'); 
    	
    	/*
        $this->load->model('user', '', true);
        if ($this->user->authenticate($this->input->post('username'), $this->input->post('password')))
        {
            $this->session->set_userdata('loggedin', true);
            redirect('/admin/home');
        }
        else
        {
            redirect('/sessions/login');
        }
        */
        
        
    }

    public function logout()
    {
    	$this->load->helper('url');	
        $this->session->unset_userdata('loggedin');
        redirect('/sessions/login');
    }
}


/* End of file myform.php */
/* Location: ./application/controllers/myform.php */
